<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      
    </style>
</head>
<body>
    <button id="btn1">全选</button>
    <button id="btn2">不选</button>
    <button id="btn3">反选</button>
    <br>
    <input type="checkbox">
    <input type="checkbox">
    <input type="checkbox">
    <input type="checkbox">
    <input type="checkbox">
   
  <script>
    btn1.onclick=function(){
        var o=document.getElementsByTagName("input")
        for(let i=0;i<o.length;i++){
            o[i].checked=true
        }
    }
    btn2.onclick=function(){
        var o=document.getElementsByTagName("input")
        for(let i=0;i<o.length;i++){
            o[i].checked=false
        }
    }
    btn3.onclick=function(){
        var o=document.getElementsByTagName("input")
        for(let i=0;i<o.length;i++){
            if(o[i].checked==true){
                o[i].checked=false
            }else{
                o[i].checked=true
            }
           
            
        }
    } 

    
        
  </script>
    
</body>
</html>